package tcc.model.entities;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import tcc.model.graph.Vertex;

/**
 * Represents the Vertexes table
 * @author Gabriel Pacheco
 *
 */
@Entity
@Table(name="VERTEXES")
public class VertexEntity {
	private int id;	
	private int positionX;
	private int positionY;
	private String rfid;

	@Id
	@Column(name="VERTEX_ID")
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	
	@Column(name="POSITION_X", nullable=false)
	public int getPositionX() {
		return positionX;
	}
	public void setPositionX(int positionX) {
		this.positionX = positionX;
	}
	
	@Column(name="POSITION_Y", nullable=false)
	public int getPositionY() {
		return positionY;
	}
	public void setPositionY(int positionY) {
		this.positionY = positionY;
	}
	
	@Column(name="RFID", nullable=false)
	public String getRfid() {
		return rfid;
	}
	public void setRfid(String rfid) {
		this.rfid = rfid;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		VertexEntity other = (VertexEntity) obj;
		if (id != other.id)
			return false;
		return true;
	}
	
	@Transient
	public Vertex getVertex() {
		return new Vertex(this.id, this.positionX, this.positionY, this.rfid); 
	}
	
}
